package com.beasts.ant.page.controller;

import com.beasts.ant.page.entity.APCommonOperation;
import com.beasts.ant.page.entity.RemindMessage;
import com.beasts.ant.page.service.ICommonOperationService;
import com.beasts.ant.page.service.IMessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 保存常用操作
 * @author cn_zkn
 * @date 07/05/2018 8:39 AM
 * @since 1.0
 */
@Controller
@RequestMapping({"/commonOperation"})
public class CommonOperationController {

    @Autowired
    private ICommonOperationService iCommonOperationService;

    /**
     * 常用操作新增
     * @return
     */
    @RequestMapping({"/updateCommonOperation"})
    @ResponseBody
    public Map saveOperation(HttpServletRequest req) {

        Map<String, Object> map = new HashMap<>();

        try {

            iCommonOperationService.saveOperation(req);
            map.put("status","0");

        }catch(Exception e){
            map.put("status","1");
        }

        return map;
    }

    /**
     * 常用操作检索
     * @return
     */
    @RequestMapping({"/selectCommonOperation"})
    @ResponseBody
    public List<APCommonOperation> selectCommonOperation(HttpServletRequest req) {
        Map<String, Object> map = new HashMap<>();
        try {

            return iCommonOperationService.findByUserId(req);

        }catch(Exception e){
            e.printStackTrace();

        }
        return  null;

    }

}
